测试链接：https://leetcode.cn/problems/fruit-into-baskets/
class Solution {
public:
    unordered_map<int, int> fruits_map;
    
    bool IsExistfruits_map(int target)
    {
        auto iter = fruits_map.find(target);


        return iter != fruits_map.end();
    }
    int totalFruit(vector<int>& fruits) {
        int ans = 0;
        for(int left = 0, right = 0; right < fruits.size(); right++)
        {
            fruits_map[fruits[right]] = right;
            //进窗口
            if(fruits_map.size() <= 2)
            {
                ans = max(ans, right - left + 1);
            }
            else
            {
                int min_map = fruits.size();
                for(auto iter = fruits_map.begin(); iter != fruits_map.end(); iter++)
                {
                    min_map = min(min_map, iter->second);
                }
                left = min_map + 1;
                fruits_map.erase(fruits[min_map]);
            }



        
            
        }

        return ans;
    }
};